package com.zzyy.study.controller;

import com.zzyy.study.common.Result;
import com.zzyy.study.common.ResultUtils;
import com.zzyy.study.entities.CreateOrderRequest;
import com.zzyy.study.service.IOrderService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @auther zzyy
 * @create 2024-07-14 15:20
 */
@RestController
public class OrderController {

    @Resource
    private IOrderService orderService;

    /**
     * 演示：创建订单，模拟投递消息
     *
     * @param req
     * @return
     */
    @PostMapping("/order/createOrder")
    public Result<String> createOrder(@Validated @RequestBody CreateOrderRequest req) {
        return ResultUtils.success(this.orderService.createOrder(req));
    }
}


/**
 * SELECT id,body_json,expect_send_time,actual_send_time,status,fail_msg,fail_count,send_retry,next_retry_time,create_time,update_time
 * FROM t_msg WHERE (((status = ? AND expect_send_time <= ?) OR (status = ? AND send_retry = ? AND next_retry_time <= ?))) ORDER BY id ASC
 */